<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: libowu
  Date: 18-10-19
  Time: 下午3:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">

    <script src="/js/sysJs/setting.js"></script>
    <link rel="stylesheet" href="/css/sysCss/setting.css">


</head>
<body>

<form action="" method="post" name="form">
    <div class="parent" id="parent">

        <!--登录界面设置-->
        <div class="model">
            <h3>登录界面设置</h3>

            <div class="settingContent">
                <span>背景</span><input type="color" value="${config.bgforlogin}" name="bgForLogin"/>
                <span hidden>登录框</span><input type="color" value="${config.bgforloginframe}" name="bgForLoginFrame" hidden/>
                <span>标题颜色</span><input type="color" value="${config.fontcolorforlogin}" name="fontColorForLogin"/>
                <span>圆角</span><input type="number" max="30" min="0" style="font-size: 12px" value="${config.circular}" name="circular"/>

                <c:if test="${sessionScope.type=='admin'}">
                    <span>登录标题</span><input type="text" style="font-size: 16px;margin-right: 0px" maxlength="60" name="loginTitle" value="${config.logintitle}"/>
                </c:if>
            </div>

        </div>

        <div class="model">
            <h3>
                框架设置
            </h3>

            <div class="settingContent">
                <span>背景</span><input type="color" value="${config.bgforframe}" name="bgForFrame"/>
                <span>任务栏</span><input type="color" value="${config.bgformissionbar}" name="bgForMissionBar"/>
                <span>应用栏</span><input type="color" value="${config.bgforappbar}" name="bgForAppBar"/>
                <span>字体颜色</span><input type="color" value="${config.fontcolor}" name="fontColor"/>
                <span>任务字体颜色</span><input type="color" value="${config.missionfontcolor}" name="missionFontColor"/>
                <span>任务背景</span><input type="color" value="${config.missionbg}" name="missionBg"/>

                <c:if test="${sessionScope.type=='admin'}">
                    <span>网站标题</span><input type="text" style="font-size: 16px;margin-right: 0px" maxlength="60" name="webTitle" value="${config.webtitle}"/>
                </c:if>
            </div>
        </div>

        <c:if test="${user.type=='admin'}">
            <div class="model">
                <h3>
                    隐藏设置（非admin用户有效）
                </h3>

                <div class="settingContent">
                    <c:if test="${config.hideuseradmin==1}">
                        <span>用户管理</span><label><span class="choose">是</span><input type="radio" name="hideUserAdmin" value="1" checked/></label> <label><span class="choose">否</span><input type="radio" name="hideUserAdmin" value="0"/></label></br></br>
                    </c:if>
                    <c:if test="${config.hideuseradmin==0}">
                        <span>用户管理</span><label><span class="choose">是</span><input type="radio" name="hideUserAdmin" value="1" /></label> <label><span class="choose">否</span><input type="radio" name="hideUserAdmin" checked value="0"/></label></br></br>
                    </c:if>

                    <c:if test="${config.hideappsetting==1}">
                        <span>应有设置</span><label><span class="choose">是</span><input type="radio" name="hideAppSetting" value="1" checked/></label> <label><span class="choose">否</span><input type="radio" name="hideAppSetting" value="0"/></label></br></br>
                    </c:if>
                    <c:if test="${config.hideappsetting==0}">
                        <span>应有设置</span><label><span class="choose">是</span><input type="radio" name="hideAppSetting" value="1"/></label> <label><span class="choose">否</span><input type="radio" name="hideAppSetting" checked value="0"/></label></br></br>
                    </c:if>

                    <c:if test="${config.hideaddapp==1}">
                        <span>添加应用</span><label><span class="choose">是</span><input type="radio" name="hideAddApp" value="1" checked/></label> <label><span class="choose">否</span><input type="radio" name="hideAddApp" value="0"/></label></br></br>
                    </c:if>
                    <c:if test="${config.hideaddapp==0}">
                        <span>添加应用</span><label><span class="choose">是</span><input type="radio" name="hideAddApp" value="1"/></label> <label><span class="choose">否</span><input type="radio" name="hideAddApp" checked value="0"/></label></br></br>
                    </c:if>



                </div>
            </div>
        </c:if>


        <div class="model">
            <h3>
                其他设置
            </h3>

            <div class="settingContent">
                <c:if test="${config.autohideappbar==1}">
                    <span>自动隐藏应用栏</span><label><span class="choose">是</span><input type="radio" name="autoHideAppBar" value="1" checked/></label> <label><span class="choose">否</span><input type="radio" name="autoHideAppBar" value="0"/></label></br></br>
                </c:if>
                <c:if test="${config.autohideappbar==0}">
                    <span>自动隐藏应用栏</span><label><span class="choose">是</span><input type="radio" name="autoHideAppBar" value="1"/></label> <label><span class="choose">否</span><input type="radio" name="autoHideAppBar" checked value="0"/></label></br></br>
                </c:if>


                <c:if test="${config.autohidemissionbar==1}">
                    <span>自动隐藏任务栏</span><label><span class="choose">是</span><input type="radio" name="autoHideMissionBar" value="1" checked/></label> <label><span class="choose">否</span><input type="radio" name="autoHideMissionBar" value="0"/></label></br></br>
                </c:if>
                <c:if test="${config.autohidemissionbar==0}">
                    <span>自动隐藏任务栏</span><label><span class="choose">是</span><input type="radio" name="autoHideMissionBar" value="1"/></label> <label><span class="choose">否</span><input type="radio" name="autoHideMissionBar" checked value="0"/></label></br></br>
                </c:if>

            </div>
        </div>

        <div class="save">
            <button type="button" class="btn btn-success" onclick="save()">保存</button>
        </div>

        <div class="fu-al" id="al">
            保存成功
        </div>
    </div>
</form>


<script type="text/javascript">

    //加载默认页面配置
    var h=document.getElementsByTagName("h3");
    var span=document.getElementsByTagName("span");
    (document.getElementById("parent")).style.backgroundColor="${config.missionbg}";
    for (var i=0;i<span.length;i++){
        span[i].style.color="${config.missionfontcolor}";
    }
    for (var i=0;i<h.length;i++){
        h[i].style.color="${config.missionfontcolor}";
    }

    if ('${login}'=='login'){
        parent.sengToLogin();
    }

    /**
     * 保存配置
     */
    function save(){
        var info;
        if ('${sessionScope.type}'=='admin'){
            info = {
                'bgforlogin': form.bgForLogin.value,
                'bgforloginframe':form.bgForLoginFrame.value,
                'fontcolorforlogin':form.fontColorForLogin.value,
                'circular':form.circular.value,
                'bgforframe':form.bgForFrame.value,
                'bgformissionbar':form.bgForMissionBar.value,
                'bgforappbar':form.bgForAppBar.value,
                'fontcolor':form.fontColor.value,
                'webtitle':form.webTitle.value,
                'hideuseradmin':form.hideUserAdmin.value,
                'hideappsetting':form.hideAppSetting.value,
                'hideaddapp':form.hideAddApp.value,
                'autohideappbar':form.autoHideAppBar.value,
                'autohidemissionbar':form.autoHideMissionBar.value,
                'logintitle':form.loginTitle.value,
                'username':'${user.name}',
                'missionfontcolor':form.missionFontColor.value,
                'missionbg':form.missionBg.value
            };
        }else {
            info = {
                'bgforlogin': form.bgForLogin.value,
                'bgforloginframe':form.bgForLoginFrame.value,
                'fontcolorforlogin':form.fontColorForLogin.value,
                'circular':form.circular.value,
                'bgforframe':form.bgForFrame.value,
                'bgformissionbar':form.bgForMissionBar.value,
                'bgforappbar':form.bgForAppBar.value,
                'fontcolor':form.fontColor.value,
                'hideuseradmin':form.hideUserAdmin.value,
                'hideappsetting':form.hideAppSetting.value,
                'hideaddapp':form.hideAddApp.value,
                'autohideappbar':form.autoHideAppBar.value,
                'autohidemissionbar':form.autoHideMissionBar.value,
                'username':'${user.name}',
                'missionfontcolor':form.missionFontColor.value,
                'missionbg':form.missionBg.value
            };
        }

        $.ajax({
            type: "post",
            url: "/futer/saveSetting",
            data:JSON.stringify(info) ,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (response, ifo) {

                if (response=='请求被拒绝，无权限访问'){
                    parent.sengToLogin();
                }

                if (response==1){
                    setTimeout(hide,2000);
                    (document.getElementById("al")).style.zIndex='999';
                    (document.getElementById("al")).style.display='block';
                    (document.getElementById("al")).style.backgroundColor='green';
                    (document.getElementById("al")).innerText='修改成功';
                    reLoadCss();
                    window.parent.loadCss()
                } else  {
                    setTimeout(hide,2000);
                    (document.getElementById("al")).style.zIndex='999';
                    (document.getElementById("al")).style.display='block';
                    (document.getElementById("al")).style.backgroundColor='red';
                    (document.getElementById("al")).innerText='修改失败';
                }
            }, error: function (err) {
                alert("修改失败！");
            }
        })
    }

</script>
</body>
</html>
